package com.drill.controller.interceptor;

import java.util.List;

import com.drill.controller.article.FrontCacheService;
import com.drill.controller.article.TbArticle;
import com.drill.controller.folder.Folder;
import com.drill.controller.folder.FolderService;
import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Page;
import com.jflyfox.jfinal.base.Paginator;

/**
* @auto ket
* @date 2016年6月28日 下午5:11:15
*/

public class FolderInterceptor implements Interceptor{
	
	FolderService folderService=new FolderService();

	@Override
	public void intercept(Invocation inv) {
		// TODO Auto-generated method stub
		inv.invoke();
		
		Controller controller=inv.getController();

		
		
		List<Folder> menus= new FolderService().getMenus();
		
		Page<TbArticle> articles=new FrontCacheService().getRecommendArticle(new Paginator(1,10), 2);
			
		
		
		controller.setAttr("menus", menus);
		
		controller.setAttr("articles", articles);
		
	}

	
}
